package com;

import java.util.Calendar;
import java.util.HashMap;

public class SessionCollection {
	private HashMap<Integer, Session> map = new HashMap<Integer, Session>();
	private static SessionCollection sessionCollection=null;	
	
	private SessionCollection(){}
	
	public static SessionCollection Instance () {
        if (sessionCollection == null) {
        	sessionCollection = new SessionCollection();
        }
        return sessionCollection;
    }	
	
	private void addSession(Session session){
		session.setId(map.size()+1);
		map.put(session.getId(), session);
	}
	
	public Session getSession(Integer i){
		if (map.get(i)==null){
			Session mySession = new Session();
			addSession(mySession);
			return mySession;
		} else{						
			return map.get(i);
		}
	}	
	public void updateSession(Session session){		
		session.setDate(Calendar.getInstance().getTime());
	}
}
